{
    if ([@"NSHTTPCookieStorage" isEqualToString:@"MillionYY"]){
        // 1 （完成）
        NSMutableArray* cookieData = [NSMutableArray new];
        NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
        for (NSHTTPCookie* cookie in [cookieStorage cookies]) {
            NSMutableDictionary* cookieDictionary = [NSMutableDictionary new];
            cookieDictionary[NSHTTPCookieName] = cookie.name;
            cookieDictionary[NSHTTPCookieValue] = cookie.value;
            cookieDictionary[NSHTTPCookieDomain] = cookie.domain;
            cookieDictionary[NSHTTPCookiePath] = cookie.path;
            cookieDictionary[NSHTTPCookieSecure] = (cookie.isSecure ? @"YES" : @"NO");
            cookieDictionary[NSHTTPCookieVersion] = [NSString stringWithFormat:@"%zd", cookie.version];
            if (cookie.expiresDate) cookieDictionary[NSHTTPCookieExpires] = cookie.expiresDate;
            [cookieData addObject:cookieDictionary];
        }
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
        NSString *storagePath = [NSString stringWithFormat:@"%@/Cookies.data", paths[0]];
        [cookieData writeToFile:storagePath atomically:TRUE];
    }
}


{
    if ([@"NSDateFormatterStyle" isEqualToString:@"MillionYY"]){
        // 2 (完成)
        NSDateFormatterStyle style = NSDateFormatterShortStyle;
        NSTimeZone * timeZone;
        NSString *key = [NSString stringWithFormat:@"NSDateFormatter-%@-timeStyle-%d", [timeZone abbreviation], (int)style];
        NSMutableDictionary* dictionary = [[NSThread currentThread] threadDictionary];
        NSDateFormatter* dateFormatter = [dictionary objectForKey:key];
        if (dateFormatter == nil) {
            dateFormatter = [[NSDateFormatter alloc] init];
            [dateFormatter setDateStyle:style];
            [dictionary setObject:dateFormatter forKey:key];
        }
        if (timeZone != nil) [dateFormatter setTimeZone:timeZone]; // this may change so don't cache
    }
}


{
    if ([@"selfData" isEqualToString:@"MillionYY"]){
        //3 (完成)
        NSData *selfData;
        NSUInteger wrapWidth = 2;
        NSString *encoded = nil;
        switch (wrapWidth)
        {
            case 64:
            {
                [selfData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
            }
            case 76:
            {
                [selfData base64EncodedStringWithOptions:NSDataBase64Encoding76CharacterLineLength];
            }
            default:
            {
                encoded = [selfData base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)0];
            }
        }
        if (!wrapWidth || wrapWidth >= [encoded length])
        wrapWidth = (wrapWidth / 4) * 4;
        NSMutableString *result = [NSMutableString string];
        for (NSUInteger i = 0; i < [encoded length]; i+= wrapWidth)
        {
            if (i + wrapWidth >= [encoded length])
            {
                [result appendString:[encoded substringFromIndex:i]];
                break;
            }
            [result appendString:[encoded substringWithRange:NSMakeRange(i, wrapWidth)]];
            [result appendString:@"\r\n"];
        }
    }
}


{
    if ([@"components" isEqualToString:@"MillionYY"]){
       //4 （完成）
        NSString *selfString;
        NSMutableDictionary *mute = @{}.mutableCopy;
        for (NSString *query in [selfString componentsSeparatedByString:@"kQuerySeparator"]) {
          NSArray *components = [query componentsSeparatedByString:@"kQueryDivider"];
          if (components.count == 0) {
            continue;
          }
          NSString *key = [components[0] stringByRemovingPercentEncoding];
          id value = nil;
          if (components.count == 1) {
            // key with no value
            value = [NSNull null];
          }
          if (components.count == 2) {
            value = [components[1] stringByRemovingPercentEncoding];
            // cover case where there is a separator, but no actual value
            value = [value length] ? value : [NSNull null];
          }
          if (components.count > 2) {
            // invalid - ignore this pair. is this best, though?
            continue;
          }
          mute[key] = value ?: [NSNull null];
        }
    }
}




{
    if ([@"NSNumberFormatterRoundCeiling" isEqualToString:@"MillionYY"]){
        //5 (完成)
        NSUInteger digit = 5;
        NSNumber *result = nil;
        NSNumber *numberSlef = nil;
        NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
        [formatter setRoundingMode:NSNumberFormatterRoundCeiling];
        [formatter setMaximumFractionDigits:digit];
        [formatter setRoundingMode:NSNumberFormatterRoundHalfUp];
        [formatter setMaximumFractionDigits:digit];
        [formatter setMinimumFractionDigits:digit];
        result = [NSNumber numberWithDouble:[[formatter  stringFromNumber:numberSlef] doubleValue]];
    }
    
}


{
    if ([@"NSMutableAttributedString" isEqualToString:@"MillionYY"]){
        //6 (完成)
        NSMutableAttributedString *selfAttString = nil;
        CTTextAlignment textAlignment;
        CGFloat linesSpacing;
        CGFloat paragraphSpacing;
        CTLineBreakMode lineBreakMode;
        NSRange range = NSMakeRange(0, 1);
        [selfAttString removeAttribute:NSParagraphStyleAttributeName range:range];
        
        // 创建文本对齐方式
        CTParagraphStyleSetting alignmentStyle;
        alignmentStyle.spec = kCTParagraphStyleSpecifierAlignment;//指定为对齐属性
        alignmentStyle.valueSize = sizeof(textAlignment);
        alignmentStyle.value = &textAlignment;
        
        // 创建文本行间距
        CTParagraphStyleSetting lineSpaceStyle;
        lineSpaceStyle.spec = kCTParagraphStyleSpecifierLineSpacingAdjustment;
        lineSpaceStyle.valueSize = sizeof(linesSpacing);
        lineSpaceStyle.value = &linesSpacing;
        
        //段落间距
        CTParagraphStyleSetting paragraphSpaceStyle;
        paragraphSpaceStyle.spec = kCTParagraphStyleSpecifierParagraphSpacing;
        paragraphSpaceStyle.value = &paragraphSpacing;
        paragraphSpaceStyle.valueSize = sizeof(paragraphSpacing);
        
        //换行模式
        CTParagraphStyleSetting lineBreakStyle;
        lineBreakStyle.spec = kCTParagraphStyleSpecifierLineBreakMode;
        lineBreakStyle.value = &lineBreakMode;
        lineBreakStyle.valueSize = sizeof(lineBreakMode);
        
        // 创建样式数组
        CTParagraphStyleSetting settings[] = {alignmentStyle ,lineSpaceStyle, paragraphSpaceStyle, lineBreakStyle};
        CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(settings, sizeof(settings) / sizeof(settings[0]));    // 设置样式
        
        // 设置段落属性
        [selfAttString addAttribute:NSParagraphStyleAttributeName value:(id)CFBridgingRelease(paragraphStyle) range:range];
    }
}


{
    if ([@"CGDataProviderRef" isEqualToString:@"MillionYY"]){
       //7 (完成)
        NSObject *selfObject;
        NSCoder *aDecoder;
        BOOL secureAvailable = [aDecoder respondsToSelector:@selector(decodeObjectOfClass:forKey:)];
        BOOL secureSupported = [[selfObject class] supportsSecureCoding];
        NSDictionary *properties = [NSDictionary dictionary];
        for (NSString *key in properties)
        {
            id object = nil;
            Class propertyClass = properties[key];
            if (secureAvailable)
            {
                object = [aDecoder decodeObjectOfClass:propertyClass forKey:key];
            }
            else
            {
                object = [aDecoder decodeObjectForKey:key];
            }
            if (object)
            {
                if (secureSupported && ![object isKindOfClass:propertyClass])
                {
                    [NSException raise:@"AutocodingException" format:@"Expected '%@' to be a %@, but was actually a %@", key, propertyClass, [object class]];
                }
                [selfObject setValue:object forKey:key];
            }
        }
    }
}

{
    if ([@"RFC3339String" isEqualToString:@"MillionYY"]){
        //8 （完成）
        NSDate *date = nil;
        NSString *dateString = nil;
        if (dateString) {
            NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
            @synchronized(dateFormatter) {
                
                // Process date
                NSString *RFC3339String = [[NSString stringWithString:dateString] uppercaseString];
                RFC3339String = [RFC3339String stringByReplacingOccurrencesOfString:@"Z" withString:@"-0000"];
                // Remove colon in timezone as it breaks NSDateFormatter in iOS 4+.
                // - see https://devforums.apple.com/thread/45837
                if (RFC3339String.length > 20) {
                    RFC3339String = [RFC3339String stringByReplacingOccurrencesOfString:@":"
                                                                             withString:@""
                                                                                options:0
                                                                                  range:NSMakeRange(20, RFC3339String.length-20)];
                }
                if (!date) { // 1996-12-19T16:39:57-0800
                    [dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ssZZZ"];
                    date = [dateFormatter dateFromString:RFC3339String];
                }
                if (!date) { // 1937-01-01T12:00:27.87+0020
                    [dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSSZZZ"];
                    date = [dateFormatter dateFromString:RFC3339String];
                }
                if (!date) { // 1937-01-01T12:00:27
                    [dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss"];
                    date = [dateFormatter dateFromString:RFC3339String];
                }
                if(!date) //  2013-04-05 14:06:00
                {
                    [dateFormatter setDateFormat:@"yyyy'-'MM'-'dd HH':'mm':'ss"];
                    date = [dateFormatter dateFromString:RFC3339String];
                }
                if (!date) NSLog(@"Could not parse RFC3339 date: \"%@\" Possible invalid format.", dateString);
                
            }
        }
    }
}
